
package character_6;

import java.util.Scanner;

public class Character_6 {

    public static void main(String[] args) {
//        demoMagician();
//        
        ArrayList names = new ArrayList();
        collectNameTo(names);
        System.out.println("访客名单：");
        printNames(names);
//        
        ConsoleGame guessGame = new ConsoleGame();
        //guessGame.go();
//        new Other(10).doService();
//         Other s = new Other(1);
//         s.doService();
//         System.out.println(new Some(11).hashCode());
        //new Other(10);
        new Some();
    }
    static void demoMagician(){
        Magician magician = new Magician();
        magician.setName("张三");
        magician.setLevel(1);
        magician.setBlood(100);
        System.out.println("魔法师："+magician.getName()+"  等级："+magician.getLevel()+"  血量："+magician.getBlood());
        
        showBlood(magician);
        drawFight(magician);
        System.out.println(magician.toString());
        
    }
    
    static void showBlood(Role role){
        System.out.println("血量"+role.getName()+role.getBlood());
    }
    
    static void drawFight(Role role){
        System.out.println(role.getName());
        role.fight();
    }
    
    static void collectNameTo(ArrayList names){//传值调用，非常好
        Scanner console = new Scanner(System.in);
        while (true) {            
            System.out.print("访客名称：");
            String name = console.nextLine();
            if(name.equals("q")){
                break;
            }
            names.add(name);
        }
    }
    
    static void printNames(ArrayList names){
        for (int i = 0; i < names.size(); i++) {
            String name = (String) names.get(i);
            System.out.println(names.get(i));
        }
    }
    
}
class Some{
    protected int x;

    Some() {
        this(250);
        System.out.println("Some()");
    }
    
    Some(int x) {
        this.x = x;
        System.out.println("Some(int x)");
    }
    @Override
    public int hashCode(){
        return 99;
    }
    void doService(){
        System.out.println("Some");
    }
    
    
}
class Other extends Some{

    Other() {
        super(10);
        System.out.println("Other()");
    }

    Other(int y) {
        System.out.println("Other(int y)");
    }
    
    @Override
    void doService(){
        System.out.println("Other");
    }
}